#ifndef TUTORIAL_UTILS_H_INCLUDED
#define TUTORIAL_UTILS_H_INCLUDED

#ifdef N_WINDOWS

#include <NTypes.h>

#ifndef TEMP_FAILURE_RETRY
#define TEMP_FAILURE_RETRY
#endif

#ifdef N_UNICODE

#include <tchar.h>

#define main			_tmain
#define printf			_tprintf
#define sprintf			_stprintf
#define sprintf_s		_stprintf_s
#define strcpy			_tcscpy
#define strcmp			_tcscmp
#define _stricmp		_tcsicmp
#define strlen			_tcslen
#define fopen			_tfopen
#define fputc			_fputtc
#define fopen_s			_tfopen_s
#define atoi			_ttoi
#define atof			_wtof
#define getc			_gettc
#define getchar			_gettchar
#define sscanf			_stscanf
#define sscanf_s		_stscanf_s
#define fputs			_fputts
#define scanf			_tscanf
#define scanf_s			_tscanf_s
#define _makepath		_tmakepath
#define _makepath_s		_tmakepath_s
#define _splitpath_s	_tsplitpath_s
#define _splitpath		_tsplitpath
#define fgets			_fgetts
#endif

#else

#ifdef N_UNICODE
#error "Tutorial string operations do not support UNICODE"
#endif

#include <errno.h>
#ifndef TEMP_FAILURE_RETRY
#define TEMP_FAILURE_RETRY(expr) \
	({ \
		long int _res; \
		do _res = (long int) (expr); \
		while (_res == -1L && errno == EINTR); \
		_res; \
	})
#endif

#define _stricmp strcasecmp

#endif

#include "Utils.h"

#endif // TUTORIAL_UTILS_H_INCLUDED
